<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<link rel="stylesheet" href="./../css/couponproduct.css">
<script src="./../js/flexible.js"></script>

<body>
    <!-- 头部 -->
    <div class="hand">
        <a href="./index.html">&lt;</a>
        <h4>优惠卷</h4>
        <a href=""><img src="./../assets/images/header_app.png" alt=""></a>
    </div>
    <div class="propmpt">--点餐前出示手机中的优惠卷，即可享受优惠--</div>


    <!-- 渲染部分 -->
    <div class="xr">
        <ul class="info">
            <li>
                <a href="">
                    <div class="img-fl">
                        <img src="" alt="">
                    </div>
                    <div class="infor">
                        <div class="title">
                            <h4></h4>
                        </div>
                        <div class="other">
                            <h4 class="price"></h4>
                            <div class="mall-fl"></div>
                        </div>
                    </div>
                </a>

            </li>
        </ul>
    </div>



    <div class="backkk">
        <a href="index.html">首页&gt;</a>
        <a href="">优惠卷</a>
    </div>

    <!-- 底部 -->
    <div id="footer">
        <div class="more">
            <a href>更多优惠信息&gt;&gt;</a>
        </div>
        <div class="chart">
            <span class="chart-1">品牌排行</span>
            <span class="chart-2">&gt;&gt;</span>
        </div>
        <div class="login">
            <div class="row-1">
                <a href="">
                    <div>登入</div>
                </a>
                <a href="">
                    <div>注册</div>
                </a>
                <a href="">
                    <div>返回顶部</div>
                </a>
            </div>
            <div class="row-2">
                <p>
                    <a href="">手机APP下载</a>
                    <a href="">慢慢买手机版</a>
                    "--掌上比价平台"
                </p>
                <p>m.manmanbuy.com </p>
            </div>

        </div>
    </div>
</body>

</html>
<script>

</script>
<script src="https: //cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
    //   fetch("http://chst.vip:1234/api/getcouponproduct="+couponId)
    //         .then(body => body.json())
    //         .then(ree => {
    //             console.log(ree, 666);
    //             let html = "";
    //             let ab = document.querySelectorAll(".ab")
    //             ree.result.forEach(item => {
    //                 html += `
    //                 <li productId=${item.productId}>
    //                     ${item.productImg}
    //                     <b>${item.productName}</b>
    //                     </li>
    //                 `
    //             })
    //             ab.innerHTML = html
    //         })




    //   getcouponproduct ? couponid = 1
    //    请求内容
    //    fetch(`http://chst.vip:1234/api/getcouponproduct?couponid = ${couponid}`)
    // function getUrlParms(name) {
    //     var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    //     var r = window.location.search.substr(1).match(reg);
    //     if (r != null) return r[2]; return null;
    // }
    // var couponProductId = getUrlParms("couponProductId");
    // var nameOne = getUrlParms("couponProductName");
    // console.log(decodeURI(nameOne), 7777);

    function getUrlParms(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return r[2]; return null;
    }
    var couponProductId = getUrlParms("couponProductId");
    var nameOne = getUrlParms("couponProductName");
    console.log(decodeURI(nameOne), 7777);
    let couponId = document.querySelector("coupoId")

    
    fetch(`http://chst.vip:1234/api/getcouponproduct?couponId = ${couponId}`)

        .then(body => body.json())
        .then(res => {
            console.log(res, 666);
            let html = "";
            let ab = document.querySelectorAll(".xr")
            ree.result.forEach(item => {

                html += `
                <li productId=${item.couponProductId}>
                   <div> ${item.couponProductImg}</div>  
                    <div>
                        <div>
                    <h4>${item.couponProductName}</h4>
                        </div>
                    </div>
                    <div>
                    <a4>${item.couponProductPrice}</h4>
                    </div>
                    <div>${item.couponProductTime}</div>
                    </li>

                `
            })

            xr.innerHTML = html


        })

</script>